package com.acme.bankapp.domain.bank;

/**
 * Created by Student on 22.08.2014.
 */
public class ClientBuilder {
    private Account account;
    private String name;
    private Gender gender;
    private double balance;
    private double overdraft;
    private String accountType;

    public ClientBuilder withName(String name){
        this.name = name;
        return this;
    }

    public ClientBuilder withGender (Gender gender){
        this.gender=gender;
        return this;
    }

    public ClientBuilder withAccountType (String s){
        accountType = s;
        return this;
    }

    public ClientBuilder balance (double balance){
        this.balance =  balance;
        return this;
    }

    public ClientBuilder withBalance(double balance) {
        this.balance = balance;
        return this;
    }

    public ClientBuilder withOverdraft(Double overdraft) {
        this.overdraft = overdraft;
        return this;
    }

    public Client build() {
        return new Client(name,gender,buildAccount());

    }

    private Account buildAccount() {
        switch (accountType) {
            case "s":
                return new SavingAccount(balance);
            case "c":
                return new CheckingAccount(balance, overdraft);
            default:
                return null;
        }
    }
}
